<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div style=""></div>
    <iframe
      src="./video.html"
      frameborder="0"
      id="iframe"
      style="width: 100%; height: 100%"
    ></iframe>
    <button id="button">发送消息</button>
    <button id="button2">关闭视频</button>
  </body>

  <script>
    const iframe = document.getElementById('iframe')
    const button = document.getElementById('button')
    const button2 = document.getElementById('button2')
    button.onclick = function () {
      console.log('点击事件发生')
      iframe.contentWindow.postMessage(
        { message: 'http://10.52.154.170:83/openUrl/fUqBdDy/live.m3u8' },
        '*'
      )
    }
    button2.onclick = function () {
      console.log('点击事件发生')
      iframe.contentWindow.postMessage({ message: 'close' }, '*')
    }
  </script>
</html>
